package org.mch.func.file.copyfiletofolder;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

import org.mch.biz.ui.FuncEvent;
import org.mch.biz.ui.FuncPanel;
import org.mch.swingm.ext.METextChooser;
import org.mch.swingm.obj.MItem;

/**
 * 描述：复制某个文件到某个文件夹下的所有文件夹中；<BR/>
 * 
 * @author mch
 *
 */
public class ClientPanel extends FuncPanel {
	private static final long serialVersionUID = 1L;
	private JPanel panel;
	private JButton btn_execute;
	private METextChooser text_copy_srcfile;
	private METextChooser text_copy_parantfolder;

	public ClientPanel() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		add(getPanel());
	}

	public JPanel getPanel() {
		if (this.panel == null) {
			this.panel = new JPanel();
			panel.setPreferredSize(new Dimension(200, 10));
			panel.setBorder(new LineBorder(Color.LIGHT_GRAY));
			this.panel.setLayout(null);
			panel.add(getText_copy_srcfile());
			panel.add(getText_copy_parantfolder());
			panel.add(getBtn_execute());
		}
		return this.panel;
	}

	protected FuncEvent createEvent() {
		return new ClientEvent(this);
	}

	public JButton getBtn_execute() {
		if (btn_execute == null) {
			btn_execute = new JButton("\u6267\u884C");
			btn_execute.setFont(new Font("宋体", Font.PLAIN, 16));
			btn_execute.setMargin(new Insets(2, 2, 2, 2));
			btn_execute.setBounds(10, 192, 72, 33);
			btn_execute.addActionListener(getEvent());
		}
		return btn_execute;
	}

	public METextChooser getText_copy_parantfolder() {
		if (text_copy_parantfolder == null) {
			text_copy_parantfolder = new METextChooser(new MItem("复制目标父目录："));
			text_copy_parantfolder.getFileChooser().setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);// 设置只能选择文件夹
			text_copy_parantfolder.setBounds(10, 57, 600, 33);
		}
		return text_copy_parantfolder;
	}

	public METextChooser getText_copy_srcfile() {
		if (text_copy_srcfile == null) {
			text_copy_srcfile = new METextChooser(new MItem("复制源文件："), JFileChooser.SAVE_DIALOG);
			text_copy_srcfile.setBounds(10, 12, 600, 33);
		}
		return text_copy_srcfile;
	}
}